Write-Host "Testing Swagger access..." -ForegroundColor Green

$baseUrl = "http://localhost:8080"

# Test different Swagger paths
$swaggerPaths = @(
    "/swagger",
    "/swagger/index.html",
    "/swagger/v1/swagger.json",
    "/swagger-ui",
    "/swagger-ui/index.html"
)

foreach ($path in $swaggerPaths) {
    Write-Host "`nTesting: $baseUrl$path" -ForegroundColor Cyan
    try {
        $response = Invoke-WebRequest -Uri "$baseUrl$path" -Method GET -TimeoutSec 5
        Write-Host "✅ Success: $($response.StatusCode)" -ForegroundColor Green
        if ($response.StatusCode -eq 200) {
            Write-Host "Swagger is available at: $baseUrl$path" -ForegroundColor Yellow
        }
    }
    catch {
        Write-Host "❌ Failed: $($_.Exception.Message)" -ForegroundColor Red
    }
}

# Test API directly
Write-Host "`nTesting API directly..." -ForegroundColor Cyan
try {
    $loginData = @{
        userName = "admin"
        password = "1q2w3E*"
    } | ConvertTo-Json
    
    $response = Invoke-RestMethod -Uri "$baseUrl/api/app/user-login/login" -Method POST -Body $loginData -Headers @{"Content-Type"="application/json"}
    Write-Host "✅ API test successful" -ForegroundColor Green
    Write-Host "Response: $($response | ConvertTo-Json)" -ForegroundColor Yellow
}
catch {
    Write-Host "❌ API test failed: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host "`nTest completed!" -ForegroundColor Green 